package com.service.impl;

import com.dao.UserDao;
import com.entity.User;
import com.service.UserService;
import lombok.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service("userService")
@Transactional(rollbackFor = Exception.class,readOnly = false,isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
@Setter
public class UserServiceImpl implements UserService {
    @Autowired // byType自动注入
//    @Resource
    private UserDao userDao;
    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<User> queryUser() {
        return userDao.queryUser();
    }

    @Override
    public int insertUser(User user) {
        int i = -1;
        i = userDao.insertUser(user);
//        int a = 10/0;
        return i;
    }
}
